# Maintainer: Florian Pritz <bluewind@xinu.at>
# Contributor: David McInnis <dave@dave3.xyz>
# Contributor:  jyantis <yantis@yantis.net>

pkgname=python-internetarchive
pkgver=3.4.0
pkgrel=2
pkgdesc='Wrapper for the various Internet Archive APIs (IA-S3, Metadata API, etc)'
arch=('any')
url='https://github.com/jjjake/ia-wrapper'
license=('AGPL3')
depends=('python'
         'python-six'
         'python-yaml'
         'python-requests'
         'python-jsonpatch'
         'python-docopt'
         'python-jsonpointer'
         'python-args'
         'python-tqdm'
         'python-schema'
        )
makedepends=('python-setuptools')
optdepends=('python-ujson: faster json parsing'
            'python-gevent: concurrent downloads'
            'cython: speedups')
checkdepends=(python-responses
              python-pytest
             )
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/jjjake/internetarchive/archive/v${pkgver}.tar.gz")
sha256sums=('c2a037cc1dd4d6d63a539384d75cafd5fcc7e89c35b2a16f608ff59f10488073')

build() {
  cd internetarchive-${pkgver}
  python setup.py build
}

check() {
  cd internetarchive-${pkgver}

  # FIXME: tests/cli/test_ia_download.py tries to run `ia`, but the binary is not
  # installed and installing + changing $PATH does not seem to work. deselect the test for now
  pytest --deselect 'tests/cli/test_ia_download.py'
}

package() {
  cd internetarchive-${pkgver}
  python setup.py install --root="${pkgdir}" --optimize=1

  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -D -m644 README.rst "${pkgdir}/usr/share/doc/${pkgname}/README.rst"
}

# vim:set ts=2 sw=2 et:
